@extends('common.company_template')

@section('content')
    <div class="boxWidth">
        @include('common.notice_msg')
        <div class="row searchLine">
            <div class="col-xs-6 ">
                商铺名称：{{$Shops->name}}
                <input type="text" id="parent" style="display: none" value="{{$Shops->id}}">
                <a href="{{url('shop/goods/new')}}"><button id="addNew" class="btn btn-default searchBtn">新建商品</button></a>
            </div>
            <div class="col-xs-6 searchInput">
                <input type="text" id="searchInput">
                <button class="btn btn-default searchBtn" id="searchCon">搜索</button>
            </div>
        </div>
            <table class="table table-hover adminTableBg">
                <thead>
                <tr>
                    <th class="col-xs-3">名称</th>
                    <th class="col-xs-1">价格</th>
                    <th class="col-xs-1">分类</th>
                    <th class="col-xs-3">商铺</th>
                    <th class="col-xs-1">状态</th>
                    <th class="col-xs-2">时间</th>
                    <th class="col-xs-1">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php $statusName = ['待审','通过']; ?>
                @foreach($Goods as $g)
                    <tr>
                        <th class="col-xs-3 itemTd">{{$g->name}}</th>
                        <th class="col-xs-1 itemTd">{{$g->price!==''?$g->price:'自定义'}}</th>
                        <th class="col-xs-1 itemTd">{{$g->catName}}</th>
                        <th class="col-xs-3 itemTd">{{$g->shop}}</th>
                        <th class="col-xs-1 itemTd">{{$statusName[$g->status]}}</th>
                        <th class="col-xs-2 itemTd">{{$g->created_at}}</th>
                        <th class="col-xs-1 itemTd">
                            <a href="{{url('shop/goods/edit',['id' => $g->id])}}"><span >编辑</span></a>
                            <a href="{{url('shop/goods/del',['id' => $g->id])}}"><span class="redColor" id="delInput" onclick="if(!confirm('是否确认删除？'))return false">删除</span></a>
                        </th>
                    </tr>
                @endforeach
                </tbody>
            </table>
        <div class="pull-right">
            <?php
                $s=isset($_GET['s'])?$_GET['s']:'';
                if($s){
                    $url = ['s' => $s];
                }else{
                    $url = [];
                }
            ?>
            {!! $Goods->appends($url)->render() !!}
        </div>
    </div>
@stop
@section('js')
    <script>
        (function () {
            $('#searchCon').on('click',function () {
                var url = $('#searchInput').val().replace(/(^\s*)|(\s*$)/g, "");
                if(url){
                    window.location.href= "{!! url('shop/goods?s=') !!}"+url;
                }else{
                    window.location.href= "{!! url('shop/goods') !!}"
                }
            });
        })()
    </script>
@stop